import { BaseController, CoolController } from "@cool-midway/core";
import { Inject, Post, Body } from "@midwayjs/core";
import { UserFavoriteService } from "../../service/favorite";
import { UserFavoriteEntity } from "../../entity/favorite";
import { AddFavoriteDTO } from "../../dto/favorite";
import { Validate } from "@midwayjs/validate";

@CoolController({
    api: ['add'],
    entity: UserFavoriteEntity,
    service: UserFavoriteService,
})
export class UserFavoriteController extends BaseController {
    @Inject()
    userFavoriteService: UserFavoriteService;

    @Post('/add')
    @Validate()
    async addFavorite(@Body() body: AddFavoriteDTO) {
        return this.ok(await this.userFavoriteService.add(body));
    }
}